<?php

require_once '../vendor/autoload.php';

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

$connection = new AMQPStreamConnection('172.17.0.5', 5672, 'php1610a', '123456','phpa');
$channel = $connection->channel();

$channel->exchange_declare('toalluser', 'fanout', false, false, false);

$data = implode(' ', array_slice($argv, 1));
if (empty($data)) {
    $data = "info: Hello World!";
}


$msg = new AMQPMessage($data);

$channel->basic_publish($msg, 'toalluser');

echo ' [x] Sent ', $data, "\n";

$channel->close();
$connection->close();

?>
